package Demo02;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.nio.charset.StandardCharsets;

public class send {
    public static void main(String[] args) throws IOException {

        //组播发送端代码
        MulticastSocket ms=new MulticastSocket();

        String str="你好你好1号";
        byte[] bytes = str.getBytes();
        InetAddress address = InetAddress.getByName("224.0.0.0");
        int port=10086;//指定的接收本机的端口号
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, address, port);

        ms.send(dp);
        ms.close();
    }
}
